/**************************************************************************************
*
*	Copyright (C) 2009 - 2012 Brent Andrew O. Chua - See LICENSE.txt for more info.
*		
*	Filename	-	XMLDocument.h
*
*	Description -	
*
*	Comments	-	
*
*	Modification History:
*			Name			   Date					Description
*			MrCodeSushi	-	06/18/2012	-	Creation of this file
**************************************************************************************/
#ifndef _PSX_XML_DOCUMENT_H_
#define _PSX_XML_DOCUMENT_H_

#include "PulseSTD.h"
#include "../External/tinyxml2/tinyxml2.h"

namespace Pulse
{
	class XMLDocument
	{
	public:

		XMLDocument( void );

		~XMLDocument( void );

		BOOL IsValid( void );

		XMLElementPtr GetFirstChild( void );

		XMLElementPtr GetLastChild( void );

		XMLElementPtr FindChild( const CHAR *pName );

		// NOTE: New element not attached to doc.
		XMLElementPtr CreateElement( const CHAR *pName );

		// NOTE: New element attached to doc.
		XMLElementPtr CreateChild( const CHAR *pName );

		void ClearChildren( void );

		EErrorCode::Type SaveFile( const CHAR *pFilename );

	private:

		XMLDocument( const CHAR *pFilename );

		XMLDocument( tinyxml2::XMLDocument *pDoc );

		void AddChild( tinyxml2::XMLElement *pElem );

	private:

		friend XMLParser;
		friend XMLElement;	 

		BOOL m_bManageDoc;
		tinyxml2::XMLDocument *m_pDoc;
	};
}

#endif /* _PSX_XML_DOCUMENT_H_ */